package com.cn.wanxi.service;

import com.cn.wanxi.dao.NavDao;
import com.cn.wanxi.model.NavModel;

import java.util.ArrayList;
import java.util.List;

public class NavService {
    /**
     * 封装所有的导航信息到list
     *
     * @return
     */
    public List<NavModel> getNavModelListForHome() {
//        空集合：目的就是为了将所有的导航对象装入集合
        List<NavModel> navModelList = new ArrayList<>();
//        需要装几个对象，那么这个长度在哪里来？
        NavDao navDao = new NavDao();
//        navDao.setTitles();
        int length = navDao.getTitleList().size();
        String[] hrefs = navDao.getHrefs();
        List<String> stringList = navDao.getTitleList();
        for (int i = 0; i < length; i++) {
            NavModel navModel = new NavModel();
            navModel.setHref(hrefs[i]);
            navModel.setTitle(stringList.get(i));
            navModelList.add(navModel);//将导航加入到list
        }
        return navModelList;
    }
}
